package com.leyou.user.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.leyou.common.utils.RegexPatterns;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@Data
public class UserDTO {

    private Long id;

    @Pattern(regexp = RegexPatterns.USERNAME_REGEX, message = "用户名格式不正确")
    private String username;

    @JsonIgnore // 当springmvc把对象转成json字符串的时候，会忽略这个字段
    @NotNull(message = "密码不能为空")
    @Length(min = 4, max = 30, message = "密码格式不正确")
    private String password;

    @JsonIgnore // 当springmvc把对象转成json字符串的时候，会忽略这个字段
    private String confirmPassword;

    @Pattern(regexp = RegexPatterns.PHONE_REGEX, message = "手机号格式不正确")
    private String phone;

}